﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PTools.SharePointEntity.Attributes;
using Microsoft.SharePoint;

namespace PTools.SharePointEntity.CommonEntities
{
    /// <summary>
    /// This represents a Sharepoint Task
    /// </summary>
    [ListAttribute("Tasks")]
    public class Task: EntityBase
    {
        #region Properties
        /// <summary>
        /// The Title of the Task
        /// </summary>
        [FieldAttribute("Title")]
        public string Title { get; set; }

        /// <summary>
        /// The Priority of the Task
        /// </summary>
        [FieldAttribute("Priority")]
        public string Priority { get; set; }

        /// <summary>
        /// The Status of the Task
        /// </summary>
        [FieldAttribute("Status")]
        public string Status { get; set; }

        /// <summary>
        /// The percentage complete of the Task
        /// </summary>
        [FieldAttribute("PercentComplete")]
        public Double PercentComplete { get; set; }

        /// <summary>
        /// The SPUser object to which this task is assigned to
        /// </summary>
        [FieldAttribute("AssignedTo")]
        public SPUser AssignedTo {get; set; }
        
        /// <summary>
        /// The Description of the Task
        /// </summary>
        [FieldAttribute("Body")]
        public string Description { get; set; }

        /// <summary>
        /// The Start Date of the Task
        /// </summary>
        [FieldAttribute("StartDate")]
        public DateTime StartDate { get; set; }

        /// <summary>
        /// The End Date of the Task
        /// </summary>
        [FieldAttribute("DueDate")]
        public DateTime DueDate { get; set; }
        #endregion

        #region Constructor
        private SPWeb _web;

        /// <summary>
        /// This represents a Task at the URL Provided
        /// </summary>
        /// <param name="web">The SPWeb where the task should be created</param>
        public Task(SPWeb web)
        {
            _web = web;
        }
        #endregion

        #region Must Implement
        /// <summary>
        /// Returns the instance of the SPWeb Object where Task is located
        /// </summary>
        /// <returns></returns>
        public override SPWeb GetWeb()
        {
            return _web;
        }
        #endregion
    }
}

